home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Data 2002 May / CD Rom Data Mayıs 2002.iso / Freeware / Blitz Basic / data1.cab / Support / help / beginners / tutorial / deepend / 4 - complex file example uncommented.bb < prev    next >
Encoding:
Text File  |  2002-04-10  |  779 b   |  48 lines

  1.  
  2. ; -------------------------------------------------------------
  3. ; Simple file-reading example, with crude string parsing...
  4. ; -------------------------------------------------------------
  5. ; Uncommented version, to show how simple the code really is...
  6.  
  7. Graphics 640, 480
  8.  
  9. Color 150, 150, 200
  10. Text 0, 12, "Reading text from 'test.txt'..."
  11.  
  12. info = ReadFile ("test.txt")
  13.  
  14. If info
  15.  
  16.     y = 24
  17.     
  18.     Repeat
  19.  
  20.         a$ = ReadLine (info)
  21.         
  22.         Color 255, 255, 100
  23.         Text 0, y, a$
  24.                 
  25.         pos = Instr (a$, "Blitz")
  26.         
  27.         If pos
  28.  
  29.             x = StringWidth (Left (a$, pos - 1))
  30.             Color 255, 0, 0
  31.             Text x, y, "Blitz"
  32.             
  33.         EndIf
  34.  
  35.         y = y + 12
  36.  
  37.     Until Eof (info)
  38.  
  39.     CloseFile info
  40.  
  41. Else
  42.  
  43.     RuntimeError "Failed to read test.txt! Aborting..."
  44.  
  45. EndIf
  46.  
  47. MouseWait
  48. End